package client;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

public class Callback_deprecated {

	//ATTRIBUTES
	server.ICallbackHandler proxy;
	
	//GETTERS 6 SETTERS: start
	public server.ICallbackHandler getProxy() {
		return proxy;
	}

	public void setProxy(server.ICallbackHandler proxy) {
		this.proxy = proxy;
	}
	//GETTERS 6 SETTERS: end
	
	public Callback_deprecated() {
		
		String hostName = "tcm-lptp"; 
						  //"192.168.1.66";
		String portNum = "1099";
		System.setProperty("java.security.policy", "java.policy");
		
		String registryUrl = String.format("rmi://%s:%s/eexcel", hostName, portNum);
		try {
			proxy = (server.ICallbackHandler) Naming .lookup(registryUrl);
			System.out.println("Lookup completed");
			// System.out.println("Server said" + h.);
			ICallbackHandler callbackObj = new CallbackHandler(null);
			proxy.registerForCallback(callbackObj, null);
			System.out.println("Registed for callback");
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (RemoteException e) {		
			e.printStackTrace();
		} catch (NotBoundException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
